﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace OpenLightGroup.Visualizers.Controls
{
    public partial class PeakVisualizer : UserControl, IVisualizer
    {
        public PeakVisualizer()
        {
            InitializeComponent();
        }

        #region IVisualizer Members

        public void LoadParameters(params object[] values)
        {
           //not needed
        }

        public void UpdateUI(SoundBite clip)
        {

            for (int i = 0; i < this.LayoutRoot.Children.Count; i++)
            {

                UIElement target = this.LayoutRoot.Children[i];

                double height =  (clip.FrequencyChannels[i] * 1.6)*2;
                
                Storyboard board = new Storyboard();
                
                board.BeginTime = new TimeSpan(0, 0, 0, 0, 7);

                board.Children.Add(AnimationHelper.CreateHeightAnimation
                    (target, height, new Duration(new TimeSpan(0, 0, 0, 0, 5)), false));

                board.Begin();

            }

        }

        #endregion
    }
}
